#ifndef UMSDATABASE_H
#define UMSDATABASE_H


#include <QObject>
#include <QDomElement>
#include <QDomDocument>
#include "http.h"
#include "umsdata.h"
class UMSDatabase: public QObject
{
	Http *_http;
	QString _server;
	QString _user;
	QString _lastDatabase;
	bool _isOpened;
	int _port;
	QByteArray _rawdata;
	QString _lastError;
	QString soapXml(const QString &query);
	QString soapXmlCommand(const QString &command,const QString &dbname=QString(),const QString &content=QString());
	QString soapXmlCommandSetStruct(const QDomDocument &doc);
	QDomElement _currentVector;
	UMSData _data;
	QDomDocument _doc;
	void procData(QString data);
	QByteArray sendQuery(const QByteArray &data);
	void checkSelectDatabase(const QString &query);
	void setCurrentVector(QDomElement vec);
public:
	UMSDatabase(const QString &server="127.0.0.1",int port=1588);
	bool open(const QString &user,const QString &passwd);
	QString lastError();
	bool exec(const QString &query);
	void first();
	bool next();
	bool prev();
	QString server();
	QString user();
	QString lastDatabase();
	QDomElement vector();
	QByteArray rawData();
	void setHost(const QString &addr);	
        char *databaseStruct(const QString &name);
	void sendDatabaseStruct(const QDomDocument &doc);
	int answerCode();
	QString uin();
	QString value(const QString &name);
	QStringList values(const QString &name);
};	

#endif
